﻿package ${rest.packageName};

import javax.annotation.Resource;
import cn.demoncat.util.lang.entity.Result;
import cn.demoncat.util.web.annotation.GetJsonMapping;
import cn.demoncat.util.web.annotation.PostJsonMapping;
import cn.demoncat.util.web.annotation.RestMapping;
import org.springframework.web.bind.annotation.RequestBody;

import ${entity.fullName};
import ${service.packageName}.${entity.name}Service;

/** 
 * ${entity.comment} REST
 *
 * @author ${entity.author}
 *
 * @since ${entity.time}
 */
@RestMapping("/rest${entity.url}")
public class ${entity.name}Rest{

    @Resource
    private ${entity.name}Service ${entity.simpleName}Service;

    /**
     * 添加
     *
     * @param data
     * @return
     *
     * @author ${entity.author}
     *
     * @since ${entity.time}
     */
    @PostJsonMapping("/add")
    public Result add(@RequestBody ${entity.name} data){
        ${entity.simpleName}Service.save(data);
        return Result.success(data);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     *
     * @author ${entity.author}
     * @since ${entity.time}
     */
    @GetJsonMapping("/del")
    public Result del(${entity.idAttr.type} id){
        ${entity.simpleName}Service.removeById(id);
        return Result.SUCCESS;
    }

}